# !/usr/bin/env python3
# -*- coding: utf-8 -*-

# 在遇到钻石继承并且想传递不同参数的时候，基类得进行专门设计，否则子类无法正确应用super()函数具体可以参考。其中一种方式就是将中层派生类设计成接收关键字参数来进行对基类的初始化方法
# https://stackoverflow.com/questions/34884567/python-multiple-inheritance-passing-arguments-to-constructors-using-super
class Role(object):
    def __init__(self, name):
        self.name = name
        print("Init role")

    def print_name(self):
        print("My name is {}".format(self.name))


class Dev(Role):
    def __init__(self, coding, **kwargs):
        super(Dev, self).__init__(**kwargs)
        self.coding = coding
        print("Init Dev")

    # 多态：重写基类方法
    def print_name(self):
        print("I'm dev, my name is {}".format(self.name))

    def print_skill_dev(self):
        print("I'm dev, I'm good at {}".format(self.coding))


class Test(Role):
    def __init__(self, testing, **kwargs):
        super(Test, self).__init__(**kwargs)
        self.testing = testing
        print("Init Tester")

    def print_name_test(self):
        print("I'm tester, my name is {}".format(self.name))

    # 多态：重写基类方法
    def print_skill(self):
        print("I'm tester, I'm good at {}".format(self.testing))

class Person(Dev, Test):
    def __init__(self, name, coding, testing, sports):
        super(Person, self).__init__(name=name, coding=coding, testing=testing)
        self.sports = sports
        print("Init Person")

    def print_sports(self):
        print("I'm person, my favority sport is {}".format(self.sports))


# Init role
# My name is Dave
dave = Role("Dave")
dave.print_name()
print("\n")

# Init role
# Init Dev
# I'm dev, my name is Dave
# I'm dev, I'm good at Python
dave = Dev("Python", name="Dave")
dave.print_name()
dave.print_skill_dev()
print("\n")

# Init role
# Init Tester
# My name is Dave
# I'm tester, my name is Dave
# I'm tester, I'm good at AutomativeTesting
dave = Test("AutomativeTesting", name="Dave")
dave.print_name()
dave.print_name_test()
dave.print_skill()
print("\n")

# Init role
# Init Tester
# Init Dev
# Init Person
# I'm dev, my name is Dave
# I'm tester, my name is Dave
# I'm tester, I'm good at AutomativeTesting
# I'm dev, I'm good at Python
# I'm person, my favority sport is Baseketball
dave = Person("Dave", "Python", "AutomativeTesting", "Baseketball")
dave.print_name()
dave.print_name_test()
dave.print_skill()
dave.print_skill_dev()
dave.print_sports()
print("\n")